
var currency = '-';
var exchange = 1.0;
var exchange_item = 1.0;

$(function() {
	Tip.emp('负责人');
	
	$('#amount').keyup(function() {
		var a = $(this).val();
		var b = $("#currency").find("option:selected").text();
		Currency.upper(a, b, "#label_amount");
		
		_update();
	});
	
	_currency($('#currency').val());
	
	$('#currency').change(function() {
		var s = $(this).val();
		_currency(s);
	});
	
	$("input[id^='date']:visible").datepicker(_date1_option);
	
	$('textarea').css("width", 400);
});

function _currency(s) {
	if (s == null || s == '-')　{		
		return false;
	}
	
	var body = { };
	body.currency = s;
	$.post('finance.php?do=Finance.ajax_exchange', body, function(s) {
		exchange = s;
		$('#rate').val(s);
		
		_update();
	});
}

function _update() {
	var a = $("#amount").val();
	var b = $("#currency").find("option:selected").text();
	
	a = a.replace(/,/g, '');

	Currency.upper(a, b, "#label_amount");
	
	_rmb();
} 

function _rmb() {
	var a = $("#amount").val();
	var b = $('#rate').val();
	
	a = a.replace(/,/g, '');
	b = b.replace(/,/g, '');
	
	var rmb = fxmul(a, b);
	
	$('#rmb').val(rmb);	
}